﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLXuongCNTT.Object;
using QLXuongCNTT.ControlLayers;
namespace QLXuongCNTT
{
    public partial class frmGiaovien : Form
    {
        public frmGiaovien()
        {
            InitializeComponent();
        }
        ctrlGiaovien giaovien_ctr = new ctrlGiaovien();
        ctrlDMto dmto_ctr = new ctrlDMto();
        private void frmGiaovien_Load(object sender, EventArgs e)
        {
            //// TODO: This line of code loads data into the '_D__DROPBOX_CDNAG_PROJECT_QLXUONGCNTT_QLVATTU_KHOA_CNTT_QLXUONGCNTT_BIN_DEBUG_TBVT_KHOACNTT_MDFDataSet1.DANHMUCTO' table. You can move, or remove it, as needed.
            //this.dANHMUCTOTableAdapter.Fill(this._D__DROPBOX_CDNAG_PROJECT_QLXUONGCNTT_QLVATTU_KHOA_CNTT_QLXUONGCNTT_BIN_DEBUG_TBVT_KHOACNTT_MDFDataSet1.DANHMUCTO);
            bindingSource2.DataSource = dmto_ctr.getDMto();
            DataGridViewComboBoxColumn c = new DataGridViewComboBoxColumn();
            c.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            c.DataSource = bindingSource2;
            c.DataPropertyName = "mato";
            c.ValueMember = "mato";
            c.DisplayMember = "tento";
            dataGridView1.Columns.Add(c);
            
            dataGridView1.AutoGenerateColumns = false;
            bindingSource1.DataSource = giaovien_ctr.getGiaovien();
            bindingNavigator1.BindingSource = bindingSource1;
            dataGridView1.DataSource = bindingSource1;
           
        }
        
        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            giaovien_ctr.Giaovien.Magv = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            giaovien_ctr.Giaovien.Tengv = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            giaovien_ctr.Giaovien.Mato = dataGridView1.CurrentRow.Cells[2].Value.ToString();
            giaovien_ctr.AddGiaovien();
            bindingNavigator1.BindingSource.MoveLast();
        }

        private void toolStripbtnLuu_Click(object sender, EventArgs e)
        {
            bindingNavigatorPositionItem.Focus();
            if (giaovien_ctr.save() == true)
                MessageBox.Show(this, "Bạn đã lưu những thay đổi thành công!", "xác nhận", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }

        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {

        }
    }
}
